package it.uniba.di.mas.jpnde.core;

import jade.util.leap.Serializable;

public class Arc extends PNObject 
	implements Serializable, Comparable<Arc>{
	private static final long serialVersionUID = 1L;
	
	public static final String XMLNODE="arc";
	public static final String XMLINSCRIPTION_NODE="inscription";
	
	private String placeId="";
	private int weight=1;
	protected ScriptCondition condition=null;
	
	public String getPlaceId() {
		return placeId;
	}
	public void setPlaceId(String placeId) {
		this.placeId = placeId;
	}
	public int getWeight() {
		return weight;
	}
	public void setWeight(int weight) {
		this.weight = weight;
	}
	
	public ScriptCondition getCondition() {
		return condition;
	}
	public void setCondition(ScriptCondition condition) {
		this.condition = condition;
	}
	
	public int getPriority(){
		if (condition==null)
			return ScriptCondition.MAX_PRIORITY;
		else
			return condition.getPriority();
	}
	
	@Override
	public String toString() {
		return "Arch [placeId=" + placeId + ", weight=" + weight+ ", priority=" + getPriority() + "]";
	}

	@Override
	public int compareTo(Arc arc) {
		// TODO Auto-generated method stub
		if (arc.getPriority()==getPriority())
			return 0;
		if (getPriority()<arc.getPriority())
			return -1;
		else
			return 1;
	}
	
}
